<template>
	<view class="main">
	    <button class="specialthanks" @tap="navBack">返回</button>
	    <view class="spthx">
	        <view class="g1 view-ul">
				<view v-for="(item,index) in specialThanksGroupsG1" :key="index" class="view-li">
				    <text class="name" :style="{color:(item.color?item.color:'inherit')}">{{item.name}}</text>
				    <text class="comment">{{item.comment||''}}</text>
				</view>
			</view>
	        <view class="g2 view-ul">
				<view v-for="(item,index) in specialThanksGroupsG2" :key="index"  class="view-li">
				    <text class="name" :style="{color:(item.color?item.color:'inherit')}">{{item.name}}</text>
				    <text class="comment">{{item.comment||''}}</text>
				</view>
			</view>
	    </view>
		<!-- -->
	    <button class="sponsor"  style="background: linear-gradient(90deg,#946ce6,#7e5fd9); left:auto; right:50%; transform: translate(-2rem,-50%);" @tap="viewLog" >日志查看</button>
	    
		<button class="sponsor"  style="background-color:#c69; left:50%; right:auto; transform: translate(2rem,-50%);" @tap="viewProject" >项目信息</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				specialThanksGroupsG1:[],
				specialThanksGroupsG2:[],
				allSpecialThanks:[]
			}
		},
		onLoad() {
			let that = this;
			let asts = getApp().globalData.lifeRestart.app.getSpecialthanks();
			
			let specialThanksGroups ={};
			asts.sort(()=>0.5-Math.random())
			    .forEach(({group, name, comment, color})=>{
					if(!specialThanksGroups[group]){
						specialThanksGroups[group] = [];
					}
					specialThanksGroups[group].push({
						color:color,
						name:name,
						comment:comment,
						group:group
					});
				});
			// 感谢人太多，一次加载会太慢，后续优化 TODO
			setTimeout(function(){
				that.specialThanksGroupsG1 = specialThanksGroups["1"] || [];
				
			},0);
			setTimeout(function(){
				that.specialThanksGroupsG2 = specialThanksGroups["2"] || [];
			},0);
			
		},
		methods: {
			navBack(){
				uni.navigateBack({
					delta:1
				})
			},
			viewLog(){
				uni.showModal({
					title:"日志查看",
					content:"请在项目代码页面查看",
					showCancel:false,
					confirmText:"好的！"
				})
			},
			viewProject(){
				uni.showModal({
					title:"项目信息",
					content:"当前版本：1.0.0",
					showCancel:false,
					confirmText:"好的！"
				})
			}
		}
	}
</script>

<style>
	@import url("./light.css");
</style>
